package com.bys.response;

import com.bys.eunm.ResultCode;

import java.util.List;

public class R<T> {
    private int code;
    private String message;
    private T data;

    public R() {
    }

    public R(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public R(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T>R<T> success(){
        return new R(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage());
    }
    public static <T>R<T> success(T data){
        return new R(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(),data);
    }
    public static <T>R<T> customer(int code, String message){
        return new R(code,message);
    }

    public static <T>R<T> error(String message) {
        return new R(ResultCode.FAIL.getCode(),message);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
